﻿using System;
using ClieOp;
using NUnit.Framework;

namespace ClieOpTest
{
    [TestFixture]
    public class BestandTest
    {
        [Test]
        public void ToStringTest()
        {
            var bestand = new Bestand("ABC01");
            bestand.AddBatch(new Batch(1234567, new DateTime(2020, 10, 30), "N.A.A.M. Opdrachtgever"));
            var post1 = new Post((decimal)1.23, 7654321, "B. Etaler", "1234567890");
            post1.AddOmschrijving("Omschrijving 1");
            post1.AddOmschrijving("Omschrijving 2");
            bestand.Batches[0].AddPost(post1);
            var post2 = new Post((decimal)98.77, 7654321, "B. Etaler", "8888888888");
            post2.AddOmschrijving("Omschrijving 1");
            post2.AddOmschrijving("Omschrijving 2");
            bestand.Batches[0].AddPost(post2);
            string expected = "0001A" + string.Format("{0:ddMMyy}", DateTime.Today) + "CLIEOP03ABC01" + string.Format("{0:00}", DateTime.Today.Day)
                              + "011                     \r\n0010B1000012345670001EUR                          \r\n"
                              + "0030B1301020N.A.A.M. Opdrachtgever             P  \r\n0100A100200000000012300076543210001234567         \r\n"
                              + "0110BB. Etaler                                    \r\n0150A1234567890                                   \r\n"
                              + "0160AOmschrijving 1                               \r\n0160AOmschrijving 2                               \r\n"
                              + "0100A100200000000987700076543210001234567         \r\n0110BB. Etaler                                    \r\n"
                              + "0150A8888888888                                   \r\n0160AOmschrijving 1                               \r\n"
                              + "0160AOmschrijving 2                               \r\n9990A00000000000001000000177777760000002          \r\n"
                              + "9999A                                             \r\n";
            Assert.AreEqual(expected, bestand.ToString());
        }

        [Test]
        public void ZakelijkeBetalingTest()
        {
            var bestand = new Bestand("ABC01", TransactionFileType.BusinessPayments);
            bestand.AddBatch(new Batch(1234567, new DateTime(2020, 10, 30), "N.A.A.M. Opdrachtgever"));
            var post1 = new Post((decimal)1.23, 7654321, "B. Etaler", "1234567890", Post.PaymentType.CreditorBusinessPayment);
            post1.AddOmschrijving("Omschrijving 1");
            post1.AddOmschrijving("Omschrijving 2");
            bestand.Batches[0].AddPost(post1);
            var post2 = new Post((decimal)98.77, 7654321, "B. Etaler", "8888888888", Post.PaymentType.SalaryBusinessPayment);
            post2.AddOmschrijving("Omschrijving 1");
            post2.AddOmschrijving("Omschrijving 2");
            bestand.Batches[0].AddPost(post2);
            string expected = "0001A" + string.Format("{0:ddMMyy}", DateTime.Today) + "CLIEOP03ABC01" + string.Format("{0:00}", DateTime.Today.Day)
                              + "011                     \r\n0010B0000012345670001EUR                          \r\n"
                              + "0030B1301020N.A.A.M. Opdrachtgever             P  \r\n0100A000000000000012300012345670007654321         \r\n"
                              + "0170BB. Etaler                                    \r\n0150A1234567890                                   \r\n"
                              + "0160AOmschrijving 1                               \r\n0160AOmschrijving 2                               \r\n"
                              + "0100A000300000000987700012345670007654321         \r\n0170BB. Etaler                                    \r\n"
                              + "0150A8888888888                                   \r\n0160AOmschrijving 1                               \r\n"
                              + "0160AOmschrijving 2                               \r\n9990A00000000000001000000177777760000002          \r\n"
                              + "9999A                                             \r\n";
            Assert.AreEqual(expected, bestand.ToString());
        }
    }
}